package com.example.lenjor.sprite.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.example.lenjor.sprite.R;
import com.example.lenjor.sprite.bean.BeibaoInfo;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Administrator on 2017/7/2 0002.
 */
public class BeiBaoAdapter extends BaseAdapter{
    private Context context;
    private List<BeibaoInfo> data;
    private BeibaoInfo bean;
    private ImageView iv_bg;
    private TextView tv_level;
    private ImageView iv_property;
    private ImageView iv_rank;
    private ImageView iv_hero;

    public BeiBaoAdapter(Context context, List<BeibaoInfo> data){
        this.context = context;
        if(data != null){
            this.data = data;
        }else {
            data = new ArrayList<>();
        }
    }


    @Override
    public int getCount() {
        return data.size();
    }

    @Override
    public Object getItem(int position) {
        return null;
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        if(convertView == null){
            convertView = View.inflate(context,R.layout.item_veiw_beibao,null);
        }
        bean = data.get(position);
        iv_bg = (ImageView)convertView.findViewById(R.id.iv_bg);
        tv_level = (TextView) convertView.findViewById(R.id.tv_level);
        iv_property = (ImageView) convertView.findViewById(R.id.iv_property);
        iv_hero = (ImageView) convertView.findViewById(R.id.iv_hero);
        iv_rank = (ImageView) convertView.findViewById(R.id.iv_rank);

        iv_bg.setImageResource(bean.getBg());
        tv_level.setText(bean.getLevel());
        iv_property.setImageResource(bean.getProperty());
        iv_hero.setImageResource(bean.getHero());
        iv_rank.setImageResource(bean.getRank());

        return convertView;
    }
}
